package org.stu.action;

import com.opensymphony.xwork2.ActionContext;

import java.util.*;

import org.stu.action.base.*;
import org.stu.dto.*;
/**
 * @author  yeeku.H.lee kongyeeku@163.com
 * @version  1.0
 * <br>Copyright (C), 2005-2008, yeeku.H.Lee
 * <br>This program is protected by copyright laws.
 * <br>Program Name:
 * <br>Date: 
 */

public class AddExpenseAction extends BaseAction
{
	private ExpenseRecord expenseRecord;
	private ExpenseRecordType expenseRecordType;
	private String type="1";
	private User user;


	@Override
	public String execute() throws Exception
	{	Map session = ActionContext.getContext().getSession();
		expenseRecordType=expenseManager.getExpenseRecordTypeById(Integer.parseInt(type));
		user=mgr.getUser((Integer)session.get("userId"));
		expenseRecord.setType(expenseRecordType);
		expenseRecord.setUser(user);
		expenseRecord.setDate(new Date());
		expenseManager.addExpenseRecord(expenseRecord);
        return MAIN;
	}

	
	public ExpenseRecord getExpenseRecord() {
		return expenseRecord;
	}


	public void setExpenseRecord(ExpenseRecord expenseRecord) {
		this.expenseRecord = expenseRecord;
	}


	public String getType() {
		return type;
	}


	public void setType(String type) {
		this.type = type;
	}

}